
package com.canyinghao.cananimation.demo;


import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.animation.AnimatorProperty;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.DragInfo;
import ohos.agp.components.PageFlipper;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;
import ohos.multimodalinput.event.TouchEvent;

/**
 * @ProjectName: CanAnimation
 * @ClassName: FlipperAnimeAbility
 * @Description: 翻转动画
 * @Author: lr
 * @CreateDate: 2021/2/24 10:34
 */
public class FlipperAnimeAbility extends Ability implements Component.TouchEventListener, Component.DraggedListener {
    final HiLogLabel logLabel = new HiLogLabel(HiLog.LOG_APP, 0x00101, "FlipperAnimeAbility");
    PageFlipper viewFlipper;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_flipper_anime);

        viewFlipper = (PageFlipper) findComponentById(ResourceTable.Id_vf);
        viewFlipper.setDraggedListener(Component.DRAG_HORIZONTAL_VERTICAL, this);
        viewFlipper.setFlipPeriod(3000);
        viewFlipper.showNext();
        viewFlipper.showPrevious();

        AnimatorProperty lInAnim = viewFlipper.createAnimatorProperty();
        lInAnim.rotate(360).setDuration(1500);
        AnimatorProperty lOutAnim = viewFlipper.createAnimatorProperty();
        lInAnim.rotate(0).setDuration(1500);

        viewFlipper.setIncomingAnimation(lInAnim);
       // viewFlipper.setOutgoingAnimation(lOutAnim);

        if (!viewFlipper.isFlipping()) {
            viewFlipper.startFlipping();
        }


    }

    @Override
    public void onDragDown(Component component, DragInfo dragInfo) {

    }

    @Override
    public void onDragStart(Component component, DragInfo dragInfo) {

    }

    @Override
    public void onDragUpdate(Component component, DragInfo dragInfo) {

    }

    @Override
    public void onDragEnd(Component component, DragInfo dragInfo) {

    }

    @Override
    public void onDragCancel(Component component, DragInfo dragInfo) {

    }

    @Override
    public boolean onTouchEvent(Component component, TouchEvent touchEvent) {
        return false;
    }
}
